<?php

namespace common\models\cms;

use Yii;

/**
 * This is the model class for table "{{%cms_special_data}}".
 *
 * @property int $id
 * @property int $special_id 专题ID
 * @property string $cover 专题封面
 * @property string $banner 专题Banner
 * @property string|null $bg 专题背景图
 * @property string|null $bg_color 背景色值
 * @property string $route 路由扩展
 * @property int $author_id 发布人ID
 * @property int $views 浏览次数
 * @property int $created_at
 * @property int $updated_at
 */
class CmsSpecialData extends \common\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%cms_special_data}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['special_id', 'author_id', 'views', 'created_at', 'updated_at'], 'integer'],
            [['banner', 'route'], 'required'],
            [['cover', 'banner', 'bg'], 'string', 'max' => 255],
            [['bg_color'], 'string', 'max' => 30],
            [['route'], 'string', 'max' => 20],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'special_id' => '专题ID',
            'cover' => '专题封面',
            'banner' => '专题Banner',
            'bg' => '专题背景图',
            'bg_color' => '背景色值',
            'route' => '路由扩展',
            'author_id' => '发布人ID',
            'views' => '浏览次数',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    /**
     * 关联专题信息
     * @return \common\db\ActiveQuery the relational query object.
     */
    public function getSpecial() {
        return $this->hasOne(CmsSpecial::class, ['id' => 'special_id']);
    }

}
